<template>
	<view class="box">
		<view class="lan">{{detailList.department}}</view>
		<view class="lan">[病症]</view>
		<view>{{detailList.detail}}</view>
		<view class="lan">[科室]</view>
		<view>{{detailList.department}}</view>
		<view class="lan">病症详情</view>
		<view>{{detailList.disease}}眼睛闭合不了,右边脸明显动不了1</view>
		<view class="lan">[治疗经历]</view>
		<view id="zhiliao">
			<view>北京天坛医院</view>
			<view>2018.12.10-12.15</view>
		</view>

		<view>每天进行治疗,现在情况好多了，说话没那么费劲了</view>

		<view class="lan">相关图片</view>
		<view class="bingdan">

			<image src="../../static/bingdan.png" mode=""></image>

		</view>
		<view>
			<textarea v-model="comment" placeholder="请输入解答..." rows="4"></textarea>
			<button @click="submitComment" class="answerButton">我来解答</button>
			<div class="textTit">
				我的解答
			</div>
			<view v-if="comments.length > 0">
				<view style="border-radius: 30rpx;margin: 20rpx 0rpx;" v-for="(item, index) in comments" :key="index"
					class="comment-item">
					<div>
						{{ item }}
					</div>
					<button class="adopt" @click="gotoAdopt(item)">采纳意见</button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				comment: '',
				comments: [],
				detailList: [],
				adoptData: [],

			}
		},
		onLoad(options) {
			const id = options.id;
			console.log('详情id', options);
			this.getData(id);
			if (uni.getStorageSync('searchdata').length > 0) {
				this.comments = uni.getStorageSync('searchdata')
				return
			}

		},
		methods: {
			//采纳意见
			gotoAdopt(item) {
				uni.navigateTo({
					url: `/pages/AcceptedSuggestion/AcceptedSuggestion?name=${this.detailList.disease}`
				})
				console.log("1221", item);
				this.adoptData.push(item);
				uni.setStorageSync("adoptData", this.adoptData)


			},
			//详情数据
			getData(id) {
				uni.request({
					url: "http://172.27.6.151:32112/api/get/PatientDetails",
					method: "GET",
					data: {
						id: id
					}
				}).then(res => {
					console.log('详情数据', res.data.data);
					this.detailList = res.data.data
				})
			},
			submitComment() {
				if (this.comment.trim()) {
					this.comments.unshift(this.comment.trim());
					this.comment = ''; // 清空输入框
					uni.setStorageSync("searchdata", this.comments)
				} else {
					uni.showToast({
						title: '解答不能为空',
						icon: 'none'
					});
				}
			}
		}
	}
</script>

<style>
	textarea {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;

	}

	.adopt {
		background-color: #55aaff;
		color: #fff;
		margin-top: 30rpx;
	}

	.textTit {
		font-weight: 600;
		font-size: 50rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.answerButton {
		background: blue;
		color: #fff;
		border-radius: 30rpx;

	}

	.comment-item {
		margin-top: 20rpx;
		padding: 20rpx;
		border: 2px solid #ddd;

	}

	.lan {
		color: #55aaff;
		margin-top: 20rpx;
	}

	.box {
		width: 689rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		position: relative;
		background: #cfcfcf;
	}

	#zhiliao {
		display: flex;
		justify-content: space-between;
	}

	.bingdan {
		width: 98%;
		height: 280rpx;
		margin: auto;
		margin-top: 20rpx;
	}

	.bingdan image {
		width: 100%;
		height: 100%;
	}

	.di {
		position: absolute;
		bottom: 0;
		display: flex;
		justify-content: space-between;

	}

	.bi {
		width: 60vw;
		color: red;
		background-color: #fff;
	}

	.jieda {
		width: 35vw;
		background-color: #55aaff;
		color: #fff;
	}
</style>